home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 October: Mac OS SDK / Dev.CD Oct 00 SDK1.toast / Development Kits / Cross Platform / QuickTime 4.1.2 Windows SDK / CIncludes / QD3DMath.h < prev    next >
Encoding:
C/C++ Source or Header  |  2000-04-12  |  26.8 KB  |  912 lines  |  [TEXT/R*ch]

  1. /*
  2.      File:        QD3DMath.h
  3.  
  4.      Contains:    Math & matrix routines and definitions.                            
  5.  
  6.      Version:    Technology:    Quickdraw 3D 1.6
  7.                  Release:    QuickTime 4.1
  8.  
  9.      Copyright:    (c) 1995-1999 by Apple Computer, Inc., all rights reserved.
  10.  
  11.      Bugs?:        For bug reports, consult the following page on
  12.                  the World Wide Web:
  13.  
  14.                      http://developer.apple.com/bugreporter/
  15.  
  16. */
  17. #ifndef __QD3DMATH__
  18. #define __QD3DMATH__
  19.  
  20. #ifndef __QD3D__
  21.     #include <QD3D.h>
  22. #endif
  23.  
  24.  
  25. #include <float.h>
  26.  
  27.  
  28. #if PRAGMA_ONCE
  29. #pragma once
  30. #endif
  31.  
  32. #ifdef __cplusplus
  33. extern "C" {
  34. #endif
  35.  
  36. #if PRAGMA_IMPORT
  37. #pragma import on
  38. #endif
  39.  
  40. #if PRAGMA_STRUCT_ALIGN
  41.     #pragma options align=power
  42. #elif PRAGMA_STRUCT_PACKPUSH
  43.     #pragma pack(push, 2)
  44. #elif PRAGMA_STRUCT_PACK
  45.     #pragma pack(2)
  46. #endif
  47.  
  48. #if PRAGMA_ENUM_ALWAYSINT
  49.     #pragma enumsalwaysint on
  50. #elif PRAGMA_ENUM_OPTIONS
  51.     #pragma option enum=int
  52. #elif PRAGMA_ENUM_PACK
  53.     #if __option(pack_enums)
  54.         #define PRAGMA_ENUM_PACK__QD3DMATH__
  55.     #endif
  56.     #pragma options(!pack_enums)
  57. #endif
  58.  
  59. /******************************************************************************
  60.  **                                                                             **
  61.  **                            Constant Definitions                             **
  62.  **                                                                             **
  63.  *****************************************************************************/
  64. /*
  65.  *  Real zero definition
  66.  */
  67.  
  68. #ifdef FLT_EPSILON
  69.     #define kQ3RealZero            (FLT_EPSILON)
  70. #else
  71.     #define kQ3RealZero            ((float)1.19209290e-07)
  72. #endif
  73.  
  74. #ifdef FLT_MAX
  75.     #define kQ3MaxFloat            (FLT_MAX)
  76. #else
  77.     #define kQ3MaxFloat            ((float)3.40282347e+38)
  78. #endif
  79.  
  80. /*
  81.  *  Values of PI
  82.  */
  83. #define kQ3Pi                     ((float)3.1415926535898)
  84. #define kQ32Pi                     ((float)(2.0 * 3.1415926535898))
  85. #define kQ3PiOver2                ((float)(3.1415926535898 / 2.0))
  86. #define kQ33PiOver2                ((float)(3.0 * 3.1415926535898 / 2.0))
  87.  
  88.  
  89. /******************************************************************************
  90.  **                                                                             **
  91.  **                            Miscellaneous Functions                             **
  92.  **                                                                             **
  93.  *****************************************************************************/
  94. #define Q3Math_DegreesToRadians(x)    ((float)((x) *  kQ3Pi / 180.0f))
  95. #define Q3Math_RadiansToDegrees(x)    ((float)((x) * 180.0f / kQ3Pi))
  96. #define Q3Math_Min(x,y)                ((x) <= (y) ? (x) : (y))
  97. #define Q3Math_Max(x,y)                ((x) >= (y) ? (x) : (y))
  98.  
  99. /******************************************************************************
  100.  **                                                                             **
  101.  **                            Point and Vector Creation                         **
  102.  **                                                                             **
  103.  *****************************************************************************/
  104. EXTERN_API_C( TQ3Point2D *)
  105. Q3Point2D_Set                    (TQ3Point2D *            point2D,
  106.                                  float                     x,
  107.                                  float                     y);
  108.  
  109. EXTERN_API_C( TQ3Param2D *)
  110. Q3Param2D_Set                    (TQ3Param2D *            param2D,
  111.                                  float                     u,
  112.                                  float                     v);
  113.  
  114. EXTERN_API_C( TQ3Point3D *)
  115. Q3Point3D_Set                    (TQ3Point3D *            point3D,
  116.                                  float                     x,
  117.                                  float                     y,
  118.                                  float                     z);
  119.  
  120. EXTERN_API_C( TQ3RationalPoint3D *)
  121. Q3RationalPoint3D_Set            (TQ3RationalPoint3D *    point3D,
  122.                                  float                     x,
  123.                                  float                     y,
  124.                                  float                     w);
  125.  
  126. EXTERN_API_C( TQ3RationalPoint4D *)
  127. Q3RationalPoint4D_Set            (TQ3RationalPoint4D *    point4D,
  128.                                  float                     x,
  129.                                  float                     y,
  130.                                  float                     z,
  131.                                  float                     w);
  132.  
  133. EXTERN_API_C( TQ3Vector2D *)
  134. Q3Vector2D_Set                    (TQ3Vector2D *            vector2D,
  135.                                  float                     x,
  136.                                  float                     y);
  137.  
  138. EXTERN_API_C( TQ3Vector3D *)
  139. Q3Vector3D_Set                    (TQ3Vector3D *            vector3D,
  140.                                  float                     x,
  141.                                  float                     y,
  142.                                  float                     z);
  143.  
  144. EXTERN_API_C( TQ3PolarPoint *)
  145. Q3PolarPoint_Set                (TQ3PolarPoint *        polarPoint,
  146.                                  float                     r,
  147.                                  float                     theta);
  148.  
  149. EXTERN_API_C( TQ3SphericalPoint *)
  150. Q3SphericalPoint_Set            (TQ3SphericalPoint *    sphericalPoint,
  151.                                  float                     rho,
  152.                                  float                     theta,
  153.                                  float                     phi);
  154.  
  155.  
  156. /******************************************************************************
  157.  **                                                                             **
  158.  **                    Point and Vector Dimension Conversion                     **
  159.  **                                                                             **
  160.  *****************************************************************************/
  161. EXTERN_API_C( TQ3Point3D *)
  162. Q3Point2D_To3D                    (const TQ3Point2D *        point2D,
  163.                                  TQ3Point3D *            result);
  164.  
  165. EXTERN_API_C( TQ3Point2D *)
  166. Q3RationalPoint3D_To2D            (const TQ3RationalPoint3D * point3D,
  167.                                  TQ3Point2D *            result);
  168.  
  169. EXTERN_API_C( TQ3RationalPoint4D *)
  170. Q3Point3D_To4D                    (const TQ3Point3D *        point3D,
  171.                                  TQ3RationalPoint4D *    result);
  172.  
  173. EXTERN_API_C( TQ3Point3D *)
  174. Q3RationalPoint4D_To3D            (const TQ3RationalPoint4D * point4D,
  175.                                  TQ3Point3D *            result);
  176.  
  177. EXTERN_API_C( TQ3Vector3D *)
  178. Q3Vector2D_To3D                    (const TQ3Vector2D *    vector2D,
  179.                                  TQ3Vector3D *            result);
  180.  
  181. EXTERN_API_C( TQ3Vector2D *)
  182. Q3Vector3D_To2D                    (const TQ3Vector3D *    vector3D,
  183.                                  TQ3Vector2D *            result);
  184.  
  185.  
  186. /******************************************************************************
  187.  **                                                                             **
  188.  **                            Point Subtraction                                 **
  189.  **                                                                             **
  190.  *****************************************************************************/
  191. EXTERN_API_C( TQ3Vector2D *)
  192. Q3Point2D_Subtract                (const TQ3Point2D *        p1,
  193.                                  const TQ3Point2D *        p2,
  194.                                  TQ3Vector2D *            result);
  195.  
  196. EXTERN_API_C( TQ3Vector2D *)
  197. Q3Param2D_Subtract                (const TQ3Param2D *        p1,
  198.                                  const TQ3Param2D *        p2,
  199.                                  TQ3Vector2D *            result);
  200.  
  201. EXTERN_API_C( TQ3Vector3D *)
  202. Q3Point3D_Subtract                (const TQ3Point3D *        p1,
  203.                                  const TQ3Point3D *        p2,
  204.                                  TQ3Vector3D *            result);
  205.  
  206.  
  207. /******************************************************************************
  208.  **                                                                             **
  209.  **                            Point Distance                                     **
  210.  **                                                                             **
  211.  *****************************************************************************/
  212. EXTERN_API_C( float )
  213. Q3Point2D_Distance                (const TQ3Point2D *        p1,
  214.                                  const TQ3Point2D *        p2);
  215.  
  216. EXTERN_API_C( float )
  217. Q3Point2D_DistanceSquared        (const TQ3Point2D *        p1,
  218.                                  const TQ3Point2D *        p2);
  219.  
  220.  
  221. EXTERN_API_C( float )
  222. Q3Param2D_Distance                (const TQ3Param2D *        p1,
  223.                                  const TQ3Param2D *        p2);
  224.  
  225. EXTERN_API_C( float )
  226. Q3Param2D_DistanceSquared        (const TQ3Param2D *        p1,
  227.                                  const TQ3Param2D *        p2);
  228.  
  229.  
  230. EXTERN_API_C( float )
  231. Q3RationalPoint3D_Distance        (const TQ3RationalPoint3D * p1,
  232.                                  const TQ3RationalPoint3D * p2);
  233.  
  234. EXTERN_API_C( float )
  235. Q3RationalPoint3D_DistanceSquared (const TQ3RationalPoint3D * p1,
  236.                                  const TQ3RationalPoint3D * p2);
  237.  
  238.  
  239. EXTERN_API_C( float )
  240. Q3Point3D_Distance                (const TQ3Point3D *        p1,
  241.                                  const TQ3Point3D *        p2);
  242.  
  243. EXTERN_API_C( float )
  244. Q3Point3D_DistanceSquared        (const TQ3Point3D *        p1,
  245.                                  const TQ3Point3D *        p2);
  246.  
  247.  
  248. EXTERN_API_C( float )
  249. Q3RationalPoint4D_Distance        (const TQ3RationalPoint4D * p1,
  250.                                  const TQ3RationalPoint4D * p2);
  251.  
  252. EXTERN_API_C( float )
  253. Q3RationalPoint4D_DistanceSquared (const TQ3RationalPoint4D * p1,
  254.                                  const TQ3RationalPoint4D * p2);
  255.  
  256.  
  257. /******************************************************************************
  258.  **                                                                             **
  259.  **                            Point Relative Ratio                             **
  260.  **                                                                             **
  261.  *****************************************************************************/
  262. EXTERN_API_C( TQ3Point2D *)
  263. Q3Point2D_RRatio                (const TQ3Point2D *        p1,
  264.                                  const TQ3Point2D *        p2,
  265.                                  float                     r1,
  266.                                  float                     r2,
  267.                                  TQ3Point2D *            result);
  268.  
  269. EXTERN_API_C( TQ3Param2D *)
  270. Q3Param2D_RRatio                (const TQ3Param2D *        p1,
  271.                                  const TQ3Param2D *        p2,
  272.                                  float                     r1,
  273.                                  float                     r2,
  274.                                  TQ3Param2D *            result);
  275.  
  276. EXTERN_API_C( TQ3Point3D *)
  277. Q3Point3D_RRatio                (const TQ3Point3D *        p1,
  278.                                  const TQ3Point3D *        p2,
  279.                                  float                     r1,
  280.                                  float                     r2,
  281.                                  TQ3Point3D *            result);
  282.  
  283. EXTERN_API_C( TQ3RationalPoint4D *)
  284. Q3RationalPoint4D_RRatio        (const TQ3RationalPoint4D * p1,
  285.                                  const TQ3RationalPoint4D * p2,
  286.                                  float                     r1,
  287.                                  float                     r2,
  288.                                  TQ3RationalPoint4D *    result);
  289.  
  290.  
  291. /******************************************************************************
  292.  **                                                                             **
  293.  **                    Point / Vector Addition    & Subtraction                     **
  294.  **                                                                             **
  295.  *****************************************************************************/
  296. EXTERN_API_C( TQ3Point2D *)
  297. Q3Point2D_Vector2D_Add            (const TQ3Point2D *        point2D,
  298.                                  const TQ3Vector2D *    vector2D,
  299.                                  TQ3Point2D *            result);
  300.  
  301. EXTERN_API_C( TQ3Param2D *)
  302. Q3Param2D_Vector2D_Add            (const TQ3Param2D *        param2D,
  303.                                  const TQ3Vector2D *    vector2D,
  304.                                  TQ3Param2D *            result);
  305.  
  306. EXTERN_API_C( TQ3Point3D *)
  307. Q3Point3D_Vector3D_Add            (const TQ3Point3D *        point3D,
  308.                                  const TQ3Vector3D *    vector3D,
  309.                                  TQ3Point3D *            result);
  310.  
  311. EXTERN_API_C( TQ3Point2D *)
  312. Q3Point2D_Vector2D_Subtract        (const TQ3Point2D *        point2D,
  313.                                  const TQ3Vector2D *    vector2D,
  314.                                  TQ3Point2D *            result);
  315.  
  316. EXTERN_API_C( TQ3Param2D *)
  317. Q3Param2D_Vector2D_Subtract        (const TQ3Param2D *        param2D,
  318.                                  const TQ3Vector2D *    vector2D,
  319.                                  TQ3Param2D *            result);
  320.  
  321. EXTERN_API_C( TQ3Point3D *)
  322. Q3Point3D_Vector3D_Subtract        (const TQ3Point3D *        point3D,
  323.                                  const TQ3Vector3D *    vector3D,
  324.                                  TQ3Point3D *            result);
  325.  
  326.  
  327. /******************************************************************************
  328.  **                                                                             **
  329.  **                                Vector Scale                                 **
  330.  **                                                                             **
  331.  *****************************************************************************/
  332. EXTERN_API_C( TQ3Vector2D *)
  333. Q3Vector2D_Scale                (const TQ3Vector2D *    vector2D,
  334.                                  float                     scalar,
  335.                                  TQ3Vector2D *            result);
  336.  
  337. EXTERN_API_C( TQ3Vector3D *)
  338. Q3Vector3D_Scale                (const TQ3Vector3D *    vector3D,
  339.                                  float                     scalar,
  340.                                  TQ3Vector3D *            result);
  341.  
  342.  
  343. /******************************************************************************
  344.  **                                                                             **
  345.  **                                Vector Length                                 **
  346.  **                                                                             **
  347.  *****************************************************************************/
  348. EXTERN_API_C( float )
  349. Q3Vector2D_Length                (const TQ3Vector2D *    vector2D);
  350.  
  351. EXTERN_API_C( float )
  352. Q3Vector3D_Length                (const TQ3Vector3D *    vector3D);
  353.  
  354.  
  355. /******************************************************************************
  356.  **                                                                             **
  357.  **                                Vector Normalize                             **
  358.  **                                                                             **
  359.  *****************************************************************************/
  360. EXTERN_API_C( TQ3Vector2D *)
  361. Q3Vector2D_Normalize            (const TQ3Vector2D *    vector2D,
  362.                                  TQ3Vector2D *            result);
  363.  
  364. EXTERN_API_C( TQ3Vector3D *)
  365. Q3Vector3D_Normalize            (const TQ3Vector3D *    vector3D,
  366.                                  TQ3Vector3D *            result);
  367.  
  368.  
  369. /******************************************************************************
  370.  **                                                                             **
  371.  **                    Vector/Vector Addition and Subtraction                     **
  372.  **                                                                             **
  373.  *****************************************************************************/
  374. EXTERN_API_C( TQ3Vector2D *)
  375. Q3Vector2D_Add                    (const TQ3Vector2D *    v1,
  376.                                  const TQ3Vector2D *    v2,
  377.                                  TQ3Vector2D *            result);
  378.  
  379. EXTERN_API_C( TQ3Vector3D *)
  380. Q3Vector3D_Add                    (const TQ3Vector3D *    v1,
  381.                                  const TQ3Vector3D *    v2,
  382.                                  TQ3Vector3D *            result);
  383.  
  384.  
  385. EXTERN_API_C( TQ3Vector2D *)
  386. Q3Vector2D_Subtract                (const TQ3Vector2D *    v1,
  387.                                  const TQ3Vector2D *    v2,
  388.                                  TQ3Vector2D *            result);
  389.  
  390. EXTERN_API_C( TQ3Vector3D *)
  391. Q3Vector3D_Subtract                (const TQ3Vector3D *    v1,
  392.                                  const TQ3Vector3D *    v2,
  393.                                  TQ3Vector3D *            result);
  394.  
  395.  
  396. /******************************************************************************
  397.  **                                                                             **
  398.  **                                Cross Product                                 **
  399.  **                                                                             **
  400.  *****************************************************************************/
  401. EXTERN_API_C( float )
  402. Q3Vector2D_Cross                (const TQ3Vector2D *    v1,
  403.                                  const TQ3Vector2D *    v2);
  404.  
  405. EXTERN_API_C( TQ3Vector3D *)
  406. Q3Vector3D_Cross                (const TQ3Vector3D *    v1,
  407.                                  const TQ3Vector3D *    v2,
  408.                                  TQ3Vector3D *            result);
  409.  
  410. EXTERN_API_C( TQ3Vector3D *)
  411. Q3Point3D_CrossProductTri        (const TQ3Point3D *        point1,
  412.                                  const TQ3Point3D *        point2,
  413.                                  const TQ3Point3D *        point3,
  414.                                  TQ3Vector3D *            crossVector);
  415.  
  416.  
  417. /******************************************************************************
  418.  **                                                                             **
  419.  **                                Dot Product                                     **
  420.  **                                                                             **
  421.  *****************************************************************************/
  422. EXTERN_API_C( float )
  423. Q3Vector2D_Dot                    (const TQ3Vector2D *    v1,
  424.                                  const TQ3Vector2D *    v2);
  425.  
  426. EXTERN_API_C( float )
  427. Q3Vector3D_Dot                    (const TQ3Vector3D *    v1,
  428.                                  const TQ3Vector3D *    v2);
  429.  
  430.  
  431. /******************************************************************************
  432.  **                                                                             **
  433.  **                        Point and Vector Transformation                         **
  434.  **                                                                             **
  435.  *****************************************************************************/
  436. EXTERN_API_C( TQ3Vector2D *)
  437. Q3Vector2D_Transform            (const TQ3Vector2D *    vector2D,
  438.                                  const TQ3Matrix3x3 *    matrix3x3,
  439.                                  TQ3Vector2D *            result);
  440.  
  441. EXTERN_API_C( TQ3Vector3D *)
  442. Q3Vector3D_Transform            (const TQ3Vector3D *    vector3D,
  443.                                  const TQ3Matrix4x4 *    matrix4x4,
  444.                                  TQ3Vector3D *            result);
  445.  
  446. EXTERN_API_C( TQ3Point2D *)
  447. Q3Point2D_Transform                (const TQ3Point2D *        point2D,
  448.                                  const TQ3Matrix3x3 *    matrix3x3,
  449.                                  TQ3Point2D *            result);
  450.  
  451. EXTERN_API_C( TQ3Param2D *)
  452. Q3Param2D_Transform                (const TQ3Param2D *        param2D,
  453.                                  const TQ3Matrix3x3 *    matrix3x3,
  454.                                  TQ3Param2D *            result);
  455.  
  456. EXTERN_API_C( TQ3Point3D *)
  457. Q3Point3D_Transform                (const TQ3Point3D *        point3D,
  458.                                  const TQ3Matrix4x4 *    matrix4x4,
  459.                                  TQ3Point3D *            result);
  460.  
  461. EXTERN_API_C( TQ3RationalPoint4D *)
  462. Q3RationalPoint4D_Transform        (const TQ3RationalPoint4D * point4D,
  463.                                  const TQ3Matrix4x4 *    matrix4x4,
  464.                                  TQ3RationalPoint4D *    result);
  465.  
  466. EXTERN_API_C( TQ3Status )
  467. Q3Point3D_To3DTransformArray    (const TQ3Point3D *        inPoint3D,
  468.                                  const TQ3Matrix4x4 *    matrix,
  469.                                  TQ3Point3D *            outPoint3D,
  470.                                  long                     numPoints,
  471.                                  unsigned long             inStructSize,
  472.                                  unsigned long             outStructSize);
  473.  
  474. EXTERN_API_C( TQ3Status )
  475. Q3Point3D_To4DTransformArray    (const TQ3Point3D *        inPoint3D,
  476.                                  const TQ3Matrix4x4 *    matrix,
  477.                                  TQ3RationalPoint4D *    outPoint4D,
  478.                                  long                     numPoints,
  479.                                  unsigned long             inStructSize,
  480.                                  unsigned long             outStructSize);
  481.  
  482. EXTERN_API_C( TQ3Status )
  483. Q3RationalPoint4D_To4DTransformArray (const TQ3RationalPoint4D * inPoint4D,
  484.                                  const TQ3Matrix4x4 *    matrix,
  485.                                  TQ3RationalPoint4D *    outPoint4D,
  486.                                  long                     numPoints,
  487.                                  unsigned long             inStructSize,
  488.                                  unsigned long             outStructSize);
  489.  
  490.  
  491. /******************************************************************************
  492.  **                                                                             **
  493.  **                                Vector Negation                                 **
  494.  **                                                                             **
  495.  *****************************************************************************/
  496. EXTERN_API_C( TQ3Vector2D *)
  497. Q3Vector2D_Negate                (const TQ3Vector2D *    vector2D,
  498.                                  TQ3Vector2D *            result);
  499.  
  500. EXTERN_API_C( TQ3Vector3D *)
  501. Q3Vector3D_Negate                (const TQ3Vector3D *    vector3D,
  502.                                  TQ3Vector3D *            result);
  503.  
  504.  
  505. /******************************************************************************
  506.  **                                                                             **
  507.  **                    Point conversion from cartesian to polar                 **
  508.  **                                                                             **
  509.  *****************************************************************************/
  510. EXTERN_API_C( TQ3PolarPoint *)
  511. Q3Point2D_ToPolar                (const TQ3Point2D *        point2D,
  512.                                  TQ3PolarPoint *        result);
  513.  
  514. EXTERN_API_C( TQ3Point2D *)
  515. Q3PolarPoint_ToPoint2D            (const TQ3PolarPoint *    polarPoint,
  516.                                  TQ3Point2D *            result);
  517.  
  518. EXTERN_API_C( TQ3SphericalPoint *)
  519. Q3Point3D_ToSpherical            (const TQ3Point3D *        point3D,
  520.                                  TQ3SphericalPoint *    result);
  521.  
  522. EXTERN_API_C( TQ3Point3D *)
  523. Q3SphericalPoint_ToPoint3D        (const TQ3SphericalPoint * sphericalPoint,
  524.                                  TQ3Point3D *            result);
  525.  
  526.  
  527. /******************************************************************************
  528.  **                                                                             **
  529.  **                            Point Affine Combinations                         **
  530.  **                                                                             **
  531.  *****************************************************************************/
  532. EXTERN_API_C( TQ3Point2D *)
  533. Q3Point2D_AffineComb            (const TQ3Point2D *        points2D,
  534.                                  const float *            weights,
  535.                                  unsigned long             nPoints,
  536.                                  TQ3Point2D *            result);
  537.  
  538. EXTERN_API_C( TQ3Param2D *)
  539. Q3Param2D_AffineComb            (const TQ3Param2D *        params2D,
  540.                                  const float *            weights,
  541.                                  unsigned long             nPoints,
  542.                                  TQ3Param2D *            result);
  543.  
  544. EXTERN_API_C( TQ3RationalPoint3D *)
  545. Q3RationalPoint3D_AffineComb    (const TQ3RationalPoint3D * points3D,
  546.                                  const float *            weights,
  547.                                  unsigned long             numPoints,
  548.                                  TQ3RationalPoint3D *    result);
  549.  
  550. EXTERN_API_C( TQ3Point3D *)
  551. Q3Point3D_AffineComb            (const TQ3Point3D *        points3D,
  552.                                  const float *            weights,
  553.                                  unsigned long             numPoints,
  554.                                  TQ3Point3D *            result);
  555.  
  556. EXTERN_API_C( TQ3RationalPoint4D *)
  557. Q3RationalPoint4D_AffineComb    (const TQ3RationalPoint4D * points4D,
  558.                                  const float *            weights,
  559.                                  unsigned long             numPoints,
  560.                                  TQ3RationalPoint4D *    result);
  561.  
  562.  
  563. /******************************************************************************
  564.  **                                                                             **
  565.  **                                Matrix Functions                             **
  566.  **                                                                             **
  567.  *****************************************************************************/
  568. EXTERN_API_C( TQ3Matrix3x3 *)
  569. Q3Matrix3x3_Copy                (const TQ3Matrix3x3 *    matrix3x3,
  570.                                  TQ3Matrix3x3 *            result);
  571.  
  572. EXTERN_API_C( TQ3Matrix4x4 *)
  573. Q3Matrix4x4_Copy                (const TQ3Matrix4x4 *    matrix4x4,
  574.                                  TQ3Matrix4x4 *            result);
  575.  
  576.  
  577. EXTERN_API_C( TQ3Matrix3x3 *)
  578. Q3Matrix3x3_SetIdentity            (TQ3Matrix3x3 *            matrix3x3);
  579.  
  580. EXTERN_API_C( TQ3Matrix4x4 *)
  581. Q3Matrix4x4_SetIdentity            (TQ3Matrix4x4 *            matrix4x4);
  582.  
  583.  
  584. EXTERN_API_C( TQ3Matrix3x3 *)
  585. Q3Matrix3x3_Transpose            (const TQ3Matrix3x3 *    matrix3x3,
  586.                                  TQ3Matrix3x3 *            result);
  587.  
  588. EXTERN_API_C( TQ3Matrix4x4 *)
  589. Q3Matrix4x4_Transpose            (const TQ3Matrix4x4 *    matrix4x4,
  590.                                  TQ3Matrix4x4 *            result);
  591.  
  592.  
  593. EXTERN_API_C( TQ3Matrix3x3 *)
  594. Q3Matrix3x3_Invert                (const TQ3Matrix3x3 *    matrix3x3,
  595.                                  TQ3Matrix3x3 *            result);
  596.  
  597. EXTERN_API_C( TQ3Matrix4x4 *)
  598. Q3Matrix4x4_Invert                (const TQ3Matrix4x4 *    matrix4x4,
  599.                                  TQ3Matrix4x4 *            result);
  600.  
  601.  
  602. EXTERN_API_C( TQ3Matrix3x3 *)
  603. Q3Matrix3x3_Adjoint                (const TQ3Matrix3x3 *    matrix3x3,
  604.                                  TQ3Matrix3x3 *            result);
  605.  
  606.  
  607. EXTERN_API_C( TQ3Matrix3x3 *)
  608. Q3Matrix3x3_Multiply            (const TQ3Matrix3x3 *    matrixA,
  609.                                  const TQ3Matrix3x3 *    matrixB,
  610.                                  TQ3Matrix3x3 *            result);
  611.  
  612. EXTERN_API_C( TQ3Matrix4x4 *)
  613. Q3Matrix4x4_Multiply            (const TQ3Matrix4x4 *    matrixA,
  614.                                  const TQ3Matrix4x4 *    matrixB,
  615.                                  TQ3Matrix4x4 *            result);
  616.  
  617.  
  618. EXTERN_API_C( TQ3Matrix3x3 *)
  619. Q3Matrix3x3_SetTranslate        (TQ3Matrix3x3 *            matrix3x3,
  620.                                  float                     xTrans,
  621.                                  float                     yTrans);
  622.  
  623. EXTERN_API_C( TQ3Matrix3x3 *)
  624. Q3Matrix3x3_SetScale            (TQ3Matrix3x3 *            matrix3x3,
  625.                                  float                     xScale,
  626.                                  float                     yScale);
  627.  
  628.  
  629. EXTERN_API_C( TQ3Matrix3x3 *)
  630. Q3Matrix3x3_SetRotateAboutPoint    (TQ3Matrix3x3 *            matrix3x3,
  631.                                  const TQ3Point2D *        origin,
  632.                                  float                     angle);
  633.  
  634. EXTERN_API_C( TQ3Matrix4x4 *)
  635. Q3Matrix4x4_SetTranslate        (TQ3Matrix4x4 *            matrix4x4,
  636.                                  float                     xTrans,
  637.                                  float                     yTrans,
  638.                                  float                     zTrans);
  639.  
  640. EXTERN_API_C( TQ3Matrix4x4 *)
  641. Q3Matrix4x4_SetScale            (TQ3Matrix4x4 *            matrix4x4,
  642.                                  float                     xScale,
  643.                                  float                     yScale,
  644.                                  float                     zScale);
  645.  
  646.  
  647. EXTERN_API_C( TQ3Matrix4x4 *)
  648. Q3Matrix4x4_SetRotateAboutPoint    (TQ3Matrix4x4 *            matrix4x4,
  649.                                  const TQ3Point3D *        origin,
  650.                                  float                     xAngle,
  651.                                  float                     yAngle,
  652.                                  float                     zAngle);
  653.  
  654. EXTERN_API_C( TQ3Matrix4x4 *)
  655. Q3Matrix4x4_SetRotateAboutAxis    (TQ3Matrix4x4 *            matrix4x4,
  656.                                  const TQ3Point3D *        origin,
  657.                                  const TQ3Vector3D *    orientation,
  658.                                  float                     angle);
  659.  
  660. EXTERN_API_C( TQ3Matrix4x4 *)
  661. Q3Matrix4x4_SetRotate_X            (TQ3Matrix4x4 *            matrix4x4,
  662.                                  float                     angle);
  663.  
  664. EXTERN_API_C( TQ3Matrix4x4 *)
  665. Q3Matrix4x4_SetRotate_Y            (TQ3Matrix4x4 *            matrix4x4,
  666.                                  float                     angle);
  667.  
  668. EXTERN_API_C( TQ3Matrix4x4 *)
  669. Q3Matrix4x4_SetRotate_Z            (TQ3Matrix4x4 *            matrix4x4,
  670.                                  float                     angle);
  671.  
  672. EXTERN_API_C( TQ3Matrix4x4 *)
  673. Q3Matrix4x4_SetRotate_XYZ        (TQ3Matrix4x4 *            matrix4x4,
  674.                                  float                     xAngle,
  675.                                  float                     yAngle,
  676.                                  float                     zAngle);
  677.  
  678. EXTERN_API_C( TQ3Matrix4x4 *)
  679. Q3Matrix4x4_SetRotateVectorToVector (TQ3Matrix4x4 *        matrix4x4,
  680.                                  const TQ3Vector3D *    v1,
  681.                                  const TQ3Vector3D *    v2);
  682.  
  683. EXTERN_API_C( TQ3Matrix4x4 *)
  684. Q3Matrix4x4_SetQuaternion        (TQ3Matrix4x4 *            matrix,
  685.                                  const TQ3Quaternion *    quaternion);
  686.  
  687. EXTERN_API_C( float )
  688. Q3Matrix3x3_Determinant            (const TQ3Matrix3x3 *    matrix3x3);
  689.  
  690. EXTERN_API_C( float )
  691. Q3Matrix4x4_Determinant            (const TQ3Matrix4x4 *    matrix4x4);
  692.  
  693.  
  694. /******************************************************************************
  695.  **                                                                             **
  696.  **                                Quaternion Routines                             **
  697.  **                                                                             **
  698.  *****************************************************************************/
  699. EXTERN_API_C( TQ3Quaternion *)
  700. Q3Quaternion_Set                (TQ3Quaternion *        quaternion,
  701.                                  float                     w,
  702.                                  float                     x,
  703.                                  float                     y,
  704.                                  float                     z);
  705.  
  706. EXTERN_API_C( TQ3Quaternion *)
  707. Q3Quaternion_SetIdentity        (TQ3Quaternion *        quaternion);
  708.  
  709. EXTERN_API_C( TQ3Quaternion *)
  710. Q3Quaternion_Copy                (const TQ3Quaternion *    quaternion,
  711.                                  TQ3Quaternion *        result);
  712.  
  713. EXTERN_API_C( TQ3Boolean )
  714. Q3Quaternion_IsIdentity            (const TQ3Quaternion *    quaternion);
  715.  
  716. EXTERN_API_C( TQ3Quaternion *)
  717. Q3Quaternion_Invert                (const TQ3Quaternion *    quaternion,
  718.                                  TQ3Quaternion *        result);
  719.  
  720. EXTERN_API_C( TQ3Quaternion *)
  721. Q3Quaternion_Normalize            (const TQ3Quaternion *    quaternion,
  722.                                  TQ3Quaternion *        result);
  723.  
  724. EXTERN_API_C( float )
  725. Q3Quaternion_Dot                (const TQ3Quaternion *    q1,
  726.                                  const TQ3Quaternion *    q2);
  727.  
  728. EXTERN_API_C( TQ3Quaternion *)
  729. Q3Quaternion_Multiply            (const TQ3Quaternion *    q1,
  730.                                  const TQ3Quaternion *    q2,
  731.                                  TQ3Quaternion *        result);
  732.  
  733. EXTERN_API_C( TQ3Quaternion *)
  734. Q3Quaternion_SetRotateAboutAxis    (TQ3Quaternion *        quaternion,
  735.                                  const TQ3Vector3D *    axis,
  736.                                  float                     angle);
  737.  
  738. EXTERN_API_C( TQ3Quaternion *)
  739. Q3Quaternion_SetRotate_XYZ        (TQ3Quaternion *        quaternion,
  740.                                  float                     xAngle,
  741.                                  float                     yAngle,
  742.                                  float                     zAngle);
  743.  
  744. EXTERN_API_C( TQ3Quaternion *)
  745. Q3Quaternion_SetRotate_X        (TQ3Quaternion *        quaternion,
  746.                                  float                     angle);
  747.  
  748. EXTERN_API_C( TQ3Quaternion *)
  749. Q3Quaternion_SetRotate_Y        (TQ3Quaternion *        quaternion,
  750.                                  float                     angle);
  751.  
  752. EXTERN_API_C( TQ3Quaternion *)
  753. Q3Quaternion_SetRotate_Z        (TQ3Quaternion *        quaternion,
  754.                                  float                     angle);
  755.  
  756.  
  757. EXTERN_API_C( TQ3Quaternion *)
  758. Q3Quaternion_SetMatrix            (TQ3Quaternion *        quaternion,
  759.                                  const TQ3Matrix4x4 *    matrix);
  760.  
  761. EXTERN_API_C( TQ3Quaternion *)
  762. Q3Quaternion_SetRotateVectorToVector (TQ3Quaternion *    quaternion,
  763.                                  const TQ3Vector3D *    v1,
  764.                                  const TQ3Vector3D *    v2);
  765.  
  766. EXTERN_API_C( TQ3Quaternion *)
  767. Q3Quaternion_MatchReflection    (const TQ3Quaternion *    q1,
  768.                                  const TQ3Quaternion *    q2,
  769.                                  TQ3Quaternion *        result);
  770.  
  771. EXTERN_API_C( TQ3Quaternion *)
  772. Q3Quaternion_InterpolateFast    (const TQ3Quaternion *    q1,
  773.                                  const TQ3Quaternion *    q2,
  774.                                  float                     t,
  775.                                  TQ3Quaternion *        result);
  776.  
  777. EXTERN_API_C( TQ3Quaternion *)
  778. Q3Quaternion_InterpolateLinear    (const TQ3Quaternion *    q1,
  779.                                  const TQ3Quaternion *    q2,
  780.                                  float                     t,
  781.                                  TQ3Quaternion *        result);
  782.  
  783. EXTERN_API_C( TQ3Vector3D *)
  784. Q3Vector3D_TransformQuaternion    (const TQ3Vector3D *    vector3D,
  785.                                  const TQ3Quaternion *    quaternion,
  786.                                  TQ3Vector3D *            result);
  787.  
  788. EXTERN_API_C( TQ3Point3D *)
  789. Q3Point3D_TransformQuaternion    (const TQ3Point3D *        point3D,
  790.                                  const TQ3Quaternion *    quaternion,
  791.                                  TQ3Point3D *            result);
  792.  
  793.  
  794. /******************************************************************************
  795.  **                                                                             **
  796.  **                                Volume Routines                                 **
  797.  **                                                                             **
  798.  *****************************************************************************/
  799. EXTERN_API_C( TQ3BoundingBox *)
  800. Q3BoundingBox_Copy                (const TQ3BoundingBox *    src,
  801.                                  TQ3BoundingBox *        dest);
  802.  
  803. EXTERN_API_C( TQ3BoundingBox *)
  804. Q3BoundingBox_Union                (const TQ3BoundingBox *    v1,
  805.                                  const TQ3BoundingBox *    v2,
  806.                                  TQ3BoundingBox *        result);
  807.  
  808. EXTERN_API_C( TQ3BoundingBox *)
  809. Q3BoundingBox_Set                (TQ3BoundingBox *        bBox,
  810.                                  const TQ3Point3D *        min,
  811.                                  const TQ3Point3D *        max,
  812.                                  TQ3Boolean             isEmpty);
  813.  
  814. EXTERN_API_C( TQ3BoundingBox *)
  815. Q3BoundingBox_UnionPoint3D        (const TQ3BoundingBox *    bBox,
  816.                                  const TQ3Point3D *        point3D,
  817.                                  TQ3BoundingBox *        result);
  818.  
  819. EXTERN_API_C( TQ3BoundingBox *)
  820. Q3BoundingBox_UnionRationalPoint4D (const TQ3BoundingBox * bBox,
  821.                                  const TQ3RationalPoint4D * point4D,
  822.                                  TQ3BoundingBox *        result);
  823.  
  824. EXTERN_API_C( TQ3BoundingBox *)
  825. Q3BoundingBox_SetFromPoints3D    (TQ3BoundingBox *        bBox,
  826.                                  const TQ3Point3D *        points3D,
  827.                                  unsigned long             numPoints,
  828.                                  unsigned long             structSize);
  829.  
  830. EXTERN_API_C( TQ3BoundingBox *)
  831. Q3BoundingBox_SetFromRationalPoints4D (TQ3BoundingBox *    bBox,
  832.                                  const TQ3RationalPoint4D * points4D,
  833.                                  unsigned long             numPoints,
  834.                                  unsigned long             structSize);
  835.  
  836.  
  837. /******************************************************************************
  838.  **                                                                             **
  839.  **                                Sphere Routines                                 **
  840.  **                                                                             **
  841.  *****************************************************************************/
  842. EXTERN_API_C( TQ3BoundingSphere *)
  843. Q3BoundingSphere_Copy            (const TQ3BoundingSphere * src,
  844.                                  TQ3BoundingSphere *    dest);
  845.  
  846. EXTERN_API_C( TQ3BoundingSphere *)
  847. Q3BoundingSphere_Union            (const TQ3BoundingSphere * s1,
  848.                                  const TQ3BoundingSphere * s2,
  849.                                  TQ3BoundingSphere *    result);
  850.  
  851. EXTERN_API_C( TQ3BoundingSphere *)
  852. Q3BoundingSphere_Set            (TQ3BoundingSphere *    bSphere,
  853.                                  const TQ3Point3D *        origin,
  854.                                  float                     radius,
  855.                                  TQ3Boolean             isEmpty);
  856.  
  857. EXTERN_API_C( TQ3BoundingSphere *)
  858. Q3BoundingSphere_UnionPoint3D    (const TQ3BoundingSphere * bSphere,
  859.                                  const TQ3Point3D *        point3D,
  860.                                  TQ3BoundingSphere *    result);
  861.  
  862. EXTERN_API_C( TQ3BoundingSphere *)
  863. Q3BoundingSphere_UnionRationalPoint4D (const TQ3BoundingSphere * bSphere,
  864.                                  const TQ3RationalPoint4D * point4D,
  865.                                  TQ3BoundingSphere *    result);
  866.  
  867.  
  868. EXTERN_API_C( TQ3BoundingSphere *)
  869. Q3BoundingSphere_SetFromPoints3D (TQ3BoundingSphere *    bSphere,
  870.                                  const TQ3Point3D *        points3D,
  871.                                  unsigned long             numPoints,
  872.                                  unsigned long             structSize);
  873.  
  874. EXTERN_API_C( TQ3BoundingSphere *)
  875. Q3BoundingSphere_SetFromRationalPoints4D (TQ3BoundingSphere * bSphere,
  876.                                  const TQ3RationalPoint4D * points4D,
  877.                                  unsigned long             numPoints,
  878.                                  unsigned long             structSize);
  879.  
  880.  
  881.  
  882.  
  883.  
  884. #if PRAGMA_ENUM_ALWAYSINT
  885.     #pragma enumsalwaysint reset
  886. #elif PRAGMA_ENUM_OPTIONS
  887.     #pragma option enum=reset
  888. #elif defined(PRAGMA_ENUM_PACK__QD3DMATH__)
  889.     #pragma options(pack_enums)
  890. #endif
  891.  
  892. #if PRAGMA_STRUCT_ALIGN
  893.     #pragma options align=reset
  894. #elif PRAGMA_STRUCT_PACKPUSH
  895.     #pragma pack(pop)
  896. #elif PRAGMA_STRUCT_PACK
  897.     #pragma pack()
  898. #endif
  899.  
  900. #ifdef PRAGMA_IMPORT_OFF
  901. #pragma import off
  902. #elif PRAGMA_IMPORT
  903. #pragma import reset
  904. #endif
  905.  
  906. #ifdef __cplusplus
  907. }
  908. #endif
  909.  
  910. #endif /* __QD3DMATH__ */
  911.  
  912.